package com.cskaoyan.demo1.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/line")
public class LineServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //是get还是post
        String method = req.getMethod();
        System.out.println("请求行中的方法： " + method);

        //打印本地IP和计算机名称
        String localAddr = req.getLocalAddr();
        System.out.println("服务器的的IP地址： " + localAddr);
        int localPort = req.getLocalPort();
        System.out.println("服务器的端口号： " + localPort);
        String localName = req.getLocalName();
        System.out.println("请求行中的本地名称： " + localName);

        //打印客户端（远程）IP
/*        String remoteUser = req.getRemoteUser();
        System.out.println("remoteUser : " + remoteUser);*/
        String addr = req.getRemoteAddr();
        System.out.println("addr : " + addr);

        //URL和URI
        String requestURL = req.getRequestURL().toString();
        System.out.println("requestURL : " + requestURL);
        String requestURI = req.getRequestURI();
        System.out.println("requestURI : " + requestURI);

        //URL后的请求参数
        String queryString = req.getQueryString();
        System.out.println("queryString(请求行后的参数) : " + queryString);

        String protocol = req.getProtocol();
        System.out.println("protocol(协议) : " + protocol);

    }


}
